/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package manager;
import Entity.Employee;
import iface.IManager;
import java.util.ArrayList;
/**
 *
 * @author BinhNV_A04911
 */
public class EmployeeManager implements IManager<Employee> {
    private ArrayList<Employee> EmployeeList;
    public EmployeeManager(){
        this.EmployeeList= new ArrayList<Employee>();
    }

    public boolean add(Employee obj) {
        return  this.EmployeeList.add(obj);
    }

    public boolean remove(Employee obj) {
       return  this.EmployeeList.remove(obj);
    }

    public Employee replace(int index, Employee obj) {
       return  this.EmployeeList.set(index, obj);
    }

    public int size() {
       return this.EmployeeList.size();
    }

    public Employee get(int index) {
       return this.EmployeeList.get(index);
    }

    public Employee getById(int id) {
       for(Employee objEmployee:this.EmployeeList){
           if(Integer.valueOf(objEmployee.getEmployeeID())==id){
               return objEmployee;
           }
       }
       return null;
    }

    public Employee getByName(String name) {
       for(Employee obj:this.EmployeeList){
           if(obj.getEmployeeName().equals(obj)){
               return obj;
           }
       }
       return null;
    }

    public void setVisible(Employee obj, boolean value) {
       for(Employee objEmployee:this.EmployeeList){
           if(objEmployee.equals(objEmployee.getEmployeeName())){
               objEmployee.setStatus(value);
               break;
           }
       }
    }

}
